home *** CD-ROM | disk | FTP | other *** search
/ 220 Jogos / 220 jogos.iso / tetris / tetron / SOURCE / tetramino.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-12  |  2.5 KB  |  75 lines

  1. //----------------------------------------------------------------------------------------
  2. //----------------------------------------------------------------------------------------
  3. //
  4. //        Filename        :    tetramino.h
  5. //        Description        :    Header file for Tetramino class
  6. //        Author            :   Marnich van Rensburg (2002)
  7. //
  8. //----------------------------------------------------------------------------------------
  9. //----------------------------------------------------------------------------------------
  10.  
  11. #include "timer.h"
  12.  
  13. //----------------------------------------------------------------------------------------
  14. //        Constants
  15. //----------------------------------------------------------------------------------------
  16.  
  17. #ifndef TETRAMINO_H
  18. #define TETRAMINO_H
  19.  
  20. //Tetramino types
  21. #define I    1
  22. #define J    2
  23. #define L    3
  24. #define O    4
  25. #define S    5
  26. #define T    6
  27. #define Z    7
  28.  
  29. #define TET_MAX_TYPES 7
  30.  
  31. // default (x, y) starting positions
  32. #define TET_START_POS_X    0
  33. #define TET_START_POS_Y    0
  34.  
  35.  
  36.  
  37. //----------------------------------------------------------------------------------------
  38. //    Class Definition for Tetramino Class
  39. //----------------------------------------------------------------------------------------
  40.  
  41. class Tetramino
  42. {
  43.     //---------------------- Public -------------------------
  44.  
  45.     public:
  46.  
  47.         char Type;
  48.         char CurrentRotation;            // Current rotation state of tetramino
  49.         float Speed;                    // Rate at which the tetramino falls
  50.         char x, y;                        // Position in the container
  51.         Timer Tmr;                        // Used for timing fall rate 
  52.  
  53.         Tetramino();                    // Constructor
  54.         void New(char Type, unsigned int Level);    // Inits a tetrmino based on type and level passed
  55.         bool DropToNextRow();            // Returns true if the tetramino should drop to the next row
  56.         void MoveRight();                // Moves tetramino one Right
  57.         void MoveLeft();                // Moves tetramino one Left
  58.         void MoveUp();                    // Moves tetramino one Up
  59.         void MoveDown();                // Moves tetramino one Down
  60.         void RotateRight();                // Rotates the tetramino right
  61.         void RotateLeft();                // Rotates the tetramino left 
  62.         void SetMatrix(char x, char y, bool Data);    // Assigns data for teramino cell at (x, y)
  63.         bool GetMatrix(char x, char y);    // Returns the value of the teramino cell at (x, y)
  64.  
  65.     //---------------------- Private -------------------------
  66.  
  67.     private:
  68.         bool Matrix[4][4];                // Holds shape data for the tetramino in a 4x4 matrix
  69.  
  70.         // Insert tetrmino data into matrix based on type and rotation passed
  71.         void AssignData(char Type, char Rotation);
  72.  
  73. };//Class Tetramino
  74.  
  75. #endif;